from datetime import timedelta

import logging
from redis import StrictRedis
# 配置信息类
class Config(object):
    # 密钥设置
    SECRET_KEY = "ADFUOJLN"
    # 调试模式开启
    DEBUG = True
    # mysql数据库配置，链接信息和追踪提示
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@localhost:3306/information18"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis数据库配置
    redis_host = "127.0.0.1"
    redis_port = "6379"

    # session初始化信息设置
    SESSION_TYPE = "redis"  # 指定session存储类型
    SESSION_USE_SIGNER = True  # 签名存储
    SESSION_REDIS = StrictRedis(host=redis_host,port=redis_port)  # 指定session存储对象
    SESSION_PERMANENT = False  # 设置session需要过期
    PERMANENT_SESSION_LIFETIME = timedelta(days = 2)  # 设置session过期时间

    # 设置日志级别
    LEVEL_NAME = logging.DEBUG


# 开发模式配置类
class DeveloperConfig(Config):
    pass


# 生产（线上）模式配置类
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR


# 测试模式配置类
class TestConfig(Config):
    TESTING = True


# 提供配置信息访问入口
config_dict={
    "developer":DeveloperConfig,
    "Product":ProductConfig,
    "test":TestConfig
}